package NG::Sys::LogFile;
use strict;
use utf8;

use Log::Handler;

my $log_cfg;
my $log_path;

sub get_logger {
	my ($logger) = @_;
	if(Log::Handler->exists_logger($logger)){
		return Log::Handler->get_logger($logger);
	}else{
		my $log = Log::Handler->create_logger($logger);
		unless($log_cfg){
			require NG::Sys::Cfg;
			$log_cfg = NG::Sys::Cfg::config("logger");
		}
		my $cfg;
		unless($cfg = $log_cfg->{$logger}){
			$cfg = $log_cfg->{file};
			$cfg->{file}{filename} = $logger . ".log";
		}
		if($cfg->{file}){
			$cfg->{file}{filename} =~ s|.*/||;
			$cfg->{file}{filename} = $log_path . $cfg->{file}{filename};
		}
		$log->add(%$cfg);
		return $log;
	}
}

sub connect {
    my ($path) = @_;
	($log_path = $path) =~ s|/$||;
	$log_path .= "/";
}


1;
